_flavor="postmarketos-intel-medfield"
pkgname=linux-$_flavor
pkgver=6.2.7
pkgrel=1
_commit="bd6b63fadb5fb4b1637afede0ff24e1fd2456384"
pkgdesc="Mainline Kernel fork for Intel Medfield based devices"
url="https://www.kernel.org/"
arch="x86"
_carch="x86"
_config="config-$_flavor.$arch"
license="GPL-2.0-only"
options="!strip !check !tracedeps
	pmb:cross-native
"

makedepends="
	bash
	bison
	findutils
	flex
	linux-headers
	openssl-dev
	perl
	postmarketos-installkernel
	xz
"

source="
	https://gitlab.com/julianwi/linux-intel-medfield/-/archive/$_commit/linux-$_commit.tar.gz
	$_config
"
builddir="$srcdir/linux-intel-medfield-$_commit"

prepare() {
	default_prepare
	cp "$srcdir/config-$_flavor.$arch" .config
}

build() {
	unset LDFLAGS
	make ARCH="$_carch" CC="${CC:-gcc}" \
		KBUILD_BUILD_VERSION="$((pkgrel + 1))-$_flavor"
}

package() {
	mkdir -p "$pkgdir"/boot

	make install modules_install dtbs_install \
		ARCH="$_carch" INSTALL_PATH="$pkgdir"/boot \
		INSTALL_MOD_PATH="$pkgdir" INSTALL_MOD_STRIP=1 \
		INSTALL_DTBS_PATH="$pkgdir"/boot/dtbs
	rm -f "$pkgdir"/lib/modules/*/build "$pkgdir"/lib/modules/*/source

	install -D "$builddir"/include/config/kernel.release \
		"$pkgdir"/usr/share/kernel/$_flavor/kernel.release
}

sha512sums="
a9071335b9af05a30de32e0d02041cefb2f2c4a8d2ed09d21e39800002540444e699a7197b40dd0d7a1fe0f943aff4d7c1a9b9a07c75d1e59219862d27104d1e  linux-bd6b63fadb5fb4b1637afede0ff24e1fd2456384.tar.gz
b6c2c0d81890d8dea0863c500fda5297a245972ac07cd9e3833c6a7bfb4a5039af826bd9018eb43d0229e140d786a22b7cd9a9fb80601a3aabdbc56d8d932712  config-postmarketos-intel-medfield.x86
"
